<script setup>
import { ref } from 'vue'
import HomePanel from './HomePanel.vue'

// 本地模拟的“商城热卖”数据（替换为你的本地图片路径）
const hotGoodsList = ref([
  { 
    id: 1, 
    title: "智能手表", 
    alt: "多功能运动健康监测", 
    picture: new URL('@/assets/images/watch.png', import.meta.url).href 
  },
  { 
    id: 2, 
    title: "无线耳机", 
    alt: "高解析音质 降噪", 
    picture: new URL('@/assets/images/earphone.png', import.meta.url).href 
  },
  { 
    id: 3, 
    title: "便携咖啡机", 
    alt: "一键萃取 办公必备", 
    picture: new URL('@/assets/images/coffee-machine.png', import.meta.url).href 
  },
  { 
    id: 4, 
    title: "电动牙刷", 
    alt: "声波震动 洁齿护龈", 
    picture: new URL('@/assets/images/toothbrush.png', import.meta.url).href 
  }
])
</script>

<template>
  <HomePanel title="商城热卖" sub-title="商城爆款 不容错过">
    <template #main>
      <ul class="goods-list">
        <li v-for="item in hotGoodsList" :key="item.id">
          <RouterLink to="/">
            <img :src="item.picture" :alt="item.title" />
            <p class="name">{{ item.title }}</p>
            <p class="desc">{{ item.alt }}</p>
          </RouterLink>
        </li>
      </ul>
    </template>
  </HomePanel>
</template>

<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 426px;

  li {
    width: 306px;
    height: 406px;
    transition: all 0.5s;

    &:hover {
      transform: translate3d(0, -3px, 0);
      box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    }

    img {
      width: 306px;
      height: 306px;
      object-fit: cover; /* 确保图片填充容器 */
    }

    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }

    .desc {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>